package com.cloud.thread;

/**
 * @Author tangyuan2meicloud.com
 * @DATE 2021/7/21 16:02
 * @Desc
 * @Remarks
 */

/**
 * 双向检查单例模式
 */
public class DoubleCheckSingleton {
    private static volatile DoubleCheckSingleton doubleCheckSingleton = null;

    private DoubleCheckSingleton() {
    }

    static public DoubleCheckSingleton getInstance() {
        if (doubleCheckSingleton == null) {
            synchronized (DoubleCheckSingleton.class) {
                if (doubleCheckSingleton == null) {
                    doubleCheckSingleton = new DoubleCheckSingleton();
                }
            }
        }
        return doubleCheckSingleton;
    }
}
